<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2" />
    <g:set var="entityName" value="${message(code: 'activity.label', default: 'Activity')}" />
    <title>新增预约</title>
</head>

<body>
    <div class="main-body">
        <div class="page-wrapper">
            <!-- Page-header start -->
            <div class="page-header">
                <div class="page-header-title">
                    <h4>新增预约</h4>
                </div>

                <div class="page-header-breadcrumb">
                    <ul class="breadcrumb-title">
                        <li class="breadcrumb-item">
                            <a href="/salesDashboard/index">
                                <i class="icofont icofont-home"></i>
                            </a>
                        </li>
                        <li class="breadcrumb-item">
                            <g:link controller="activity" action="index">我的日历</g:link>
                        </li>
                        <li class="breadcrumb-item">新增预约</li>
                    </ul>
                </div>
            </div>
            <!-- Page-header end -->
            <!-- Page-body start -->
            <div class="page-body">
                <g:if test="${flash.message}">
                    <div class="message alert alert-info" role="status">${flash.message}
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">×</span></button>
                    </div>
                </g:if>
                <g:hasErrors bean="${this.activity}">
                    <ul class="errors" role="alert">
                        <g:eachError bean="${this.activity}" var="error">
                            <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>>
                                <g:message error="${error}" />
                            </li>
                        </g:eachError>
                    </ul>
                </g:hasErrors>
                <!-- Hover table card start -->
                <g:form action="saveAppointment" class="form-horizontal">
                    <div class="card">
                        <div class="card-header">
                            <h5>关联对象</h5>

                            <div class="card-header-right">
                                <i class="icofont icofont-rounded-down"></i>
                            </div>
                        </div>

                        <input type="hidden" name="opportunity.id" value="${this?.activity.opportunity?.id}">
                        <input type="hidden" name="asset.id" value="${this?.activity.asset?.id}">

                        <div class="card-block">
                            <!--当 flag = true， 跳转到 订单详情页-->
                            <!-- <g:textField class="form-control hide" type="text" name="flag" value="${this.params?.flag}" /> -->

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">客户</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="account.id" value="${this.activity?.account?.id}" optionValue="account" optionKey="accountId" from="${com.next.AccountTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>

                                <label class="col-md-2 col-form-label">联系人</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="contact.id" value="${this.activity?.contact?.id}" optionValue="contact" optionKey="contactId" from="${com.next.ContactTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">市场活动</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="campaign.id" value="${this.activity?.campaign?.id}" optionValue="campaign" optionKey="campaignId" from="${com.next.CampaignTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>

                                <label class="col-md-2 col-form-label">反馈</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="issue.id" value="${this.activity?.issue?.id}" optionValue="issue" optionKey="issueId" from="${com.next.IssueTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}" />
                                </div>
                            </div>

                        </div>
                    </div>

                    <div class="card">
                        <div class="card-header">
                            <h5>活动信息</h5>

                            <div class="card-header-right">
                                <i class="icofont icofont-rounded-down"></i>
                            </div>
                        </div>

                        <div class="card-block">
                            <!--当 flag = true， 跳转到 订单详情页-->
                            <!-- <g:textField class="form-control hide" type="text" name="flag"
                                          value="${this.params?.flag}"/> -->

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">标题</label>

                                <div class="col-md-3">
                                    <g:textField class="form-control" type="text" name="name" value="${this.activity?.name}" />
                                </div>

                                <label class="col-md-2 col-form-label is-required">执行人</label>

                                <div class="col-md-3">
                                    <g:select id="assignedTo" name='assignedTo.id' noSelection="${['': '请选择']}" value="${this.activity?.assignedTo?.id}" from='${com.next.User.list()}' optionKey="id" class="form-control"></g:select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">类型</label>

                                <div class="col-md-3">
                                    <g:select id="type" name='type.id' value="${com.next.ActivityType.findByName('Appointment')?.id}" from="${com.next.ActivityType.findAllByName('Appointment')}" optionKey="id" optionValue="name" class="form-control"></g:select>
                                </div>

                                <label class="col-md-2 col-form-label is-required">子类型</label>

                                <div class="col-md-3">
                                    <g:select id="subtype" name='subtype.id' noSelection="${['': '请选择']}" value="${this.activity?.subtype?.id}" from="${com.next.ActivitySubtype.findAllByType(com.next.ActivityType.findByName('Appointment'))}" optionKey="id" optionValue="name" class="form-control"></g:select>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">计划开始时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="startTime" value="${this.activity?.startTime}" precision="minute" /> --}%
                                    <div class="input-group">
                                        <input type="text" valctrl="startTime" value="${this.activity?.startTime}" class="form-control form_datetime">
                                        <input type="hidden" id="startTime" name="startTime" value="date.struct">
                                        <input type="hidden" id="startTime_minute" name="startTime_minute" value="">
                                        <input type="hidden" id="startTime_hour" name="startTime_hour" value="">
                                        <input type="hidden" id="startTime_day" name="startTime_day" value="">
                                        <input type="hidden" id="startTime_month" name="startTime_month" value="">
                                        <input type="hidden" id="startTime_year" name="startTime_year" value="">
                                    </div>                                    
                                </div>
                                <label class="col-md-2 col-form-label is-required">计划结束时间</label>

                                <div class="col-md-3 datePicker">
                                    %{-- <g:datePicker name="endTime" value="${this.activity?.endTime}" precision="minute" /> --}%
                                    <div class="input-group ">
                                        <input type="text" valctrl="endTime" value="${this.activity?.endTime}" class="form-control form_datetime">
                                        <input type="hidden" id="endTime" name="endTime" value="date.struct">
                                        <input type="hidden" id="endTime_minute" name="endTime_minute" value="">
                                        <input type="hidden" id="endTime_hour" name="endTime_hour" value="">
                                        <input type="hidden" id="endTime_day" name="endTime_day" value="">
                                        <input type="hidden" id="endTime_month" name="endTime_month" value="">
                                        <input type="hidden" id="endTime_year" name="endTime_year" value="">
                                    </div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label is-required">状态</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="status" noSelection="${['': '请选择']}" from="${this.activity.constrainedProperties.status.inList}" value="${this.activity?.status}" />
                                </div>

                                <label class="col-md-2 col-form-label">地址</label>

                                <div class="col-md-3">
                                    <g:textField class="form-control" type="text" name="address" value="${this.activity?.address}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-md-2 col-form-label">描述</label>

                                <div class="col-md-8">
                                    <g:textArea rows="3" class="form-control" name="description" id="description" value="${this.activity?.description}" />
                                </div>
                            </div>

                            <div class="form-group row">
                                <div class="col-md-12">
                                    <g:submitButton class="btn btn-info" name="update" value="保存" />
                                </div>
                            </div>

                        </div>

                    </div>

                </g:form>

                <!-- Hover table card end -->
            </div>

            <!-- Page-body end -->
        </div>
    </div>

</body>

</html>